<?php

namespace JLPay\Models\Ledger\Merchconf;

use JLPay\Models\BaseRequest;

/**
 * 商户分账绑定请求
 */
class MerchRevBindRequest extends BaseRequest
{
    /**
     * API URL
     */
    public const API_URL = '/open/ledger/merch/rev/bind';

    protected ?string $orgCode = null;
    protected ?string $mchId = null;
    protected ?string $revMchId = null;
    protected ?string $notifyUrl = null;
    protected ?array $sourceIds = null;

    /**
     * 设置机构代码
     *
     * @param string $orgCode
     * @return self
     */
    public function setOrgCode(string $orgCode): self
    {
        $this->orgCode = $orgCode;
        return $this;
    }

    /**
     * 设置商户号
     *
     * @param string $mchId
     * @return self
     */
    public function setMchId(string $mchId): self
    {
        $this->mchId = $mchId;
        return $this;
    }

    /**
     * 设置接收方商户号
     *
     * @param string $revMchId
     * @return self
     */
    public function setRevMchId(string $revMchId): self
    {
        $this->revMchId = $revMchId;
        return $this;
    }

    /**
     * 设置通知URL
     *
     * @param string $notifyUrl
     * @return self
     */
    public function setNotifyUrl(string $notifyUrl): self
    {
        $this->notifyUrl = $notifyUrl;
        return $this;
    }

    /**
     * 设置来源ID列表
     *
     * @param array $sourceIds
     * @return self
     */
    public function setSourceIds(array $sourceIds): self
    {
        $this->sourceIds = $sourceIds;
        return $this;
    }

    /**
     * 转换为数组
     *
     * @return array
     */
    public function toArray(): array
    {
        $data = parent::toArray();
        
        // 确保sourceIds作为数组传递
        if ($this->sourceIds !== null) {
            $data['source_ids'] = $this->sourceIds;
        }
        
        return $data;
    }

    /**
     * 获取机构代码
     *
     * @return string|null
     */
    public function getOrgCode(): ?string
    {
        return $this->orgCode;
    }

    /**
     * 获取商户号
     *
     * @return string|null
     */
    public function getMchId(): ?string
    {
        return $this->mchId;
    }

    /**
     * 获取接收方商户号
     *
     * @return string|null
     */
    public function getRevMchId(): ?string
    {
        return $this->revMchId;
    }

    /**
     * 获取通知URL
     *
     * @return string|null
     */
    public function getNotifyUrl(): ?string
    {
        return $this->notifyUrl;
    }

    /**
     * 获取来源ID列表
     *
     * @return array|null
     */
    public function getSourceIds(): ?array
    {
        return $this->sourceIds;
    }
} 